package com.yesep.learn.design.creational.factory;

import com.yesep.learn.design.common.*;
import com.yesep.learn.design.common.pojo.*;

public class AnimalAbstractFactory implements IAnimalAbstractFactory {
    @Override
    @SuppressWarnings("unchecked")
    public <T extends Animal> T createAnimal(String name, AnimalType animalType) throws Exception {
        Animal animal = AnimalSimpleFactory.createAnimal(animalType);
        if (animal != null) {
            animal.setName(name);
        }
        return (T) animal;
    }
}
